package com.yuwei.lesson05;

import javax.swing.*;
import java.awt.*;

public class JPanelDemo extends JFrame {
    public static void main(String[] args) {
        new JPanelDemo();
    }

    public JPanelDemo(){
        Container container = getContentPane();

        //hgap列距   vgap行距  rows行数固定  cols可变的
        container.setLayout(new GridLayout(2,1,60,30));

        //Swing中的画板
        JPanel jPanel1 = new JPanel(new GridLayout(3, 1));
        jPanel1.add(new JButton("1"));
        jPanel1.add(new JButton("1"));
        jPanel1.add(new JButton("1"));

        JPanel jPanel2 = new JPanel(new GridLayout(2, 2));
        jPanel2.add(new JButton("1"));
        jPanel2.add(new JButton("1"));
        jPanel2.add(new JButton("1"));
        jPanel2.add(new JButton("1"));

        JPanel jPanel3 = new JPanel(new GridLayout(3, 2));
        jPanel3.add(new JButton("3"));
        jPanel3.add(new JButton("3"));
        jPanel3.add(new JButton("3"));
        jPanel3.add(new JButton("3"));
        jPanel3.add(new JButton("3"));
        jPanel3.add(new JButton("3"));

        JPanel jPanel4 = new JPanel(new GridLayout(3, 3));
        jPanel4.add(new JButton("4"));
        jPanel4.add(new JButton("4"));
        jPanel4.add(new JButton("4"));
        jPanel4.add(new JButton("4"));
        jPanel4.add(new JButton("4"));
        jPanel4.add(new JButton("4"));
        jPanel4.add(new JButton("4"));
        jPanel4.add(new JButton("4"));
        jPanel4.add(new JButton("4"));

        JPanel jPanel5 = new JPanel(new GridLayout(2, 2));
        jPanel5.add(new JButton("5"));
        jPanel5.add(new JButton("5"));
        jPanel5.add(new JButton("5"));
        jPanel5.add(new JButton("5"));

        container.add(jPanel1);
        container.add(jPanel2);
        container.add(jPanel3);
        container.add(jPanel4);
        container.add(jPanel5);

        this.setSize(1000,1000);
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
}
